package xp.ass.imitate.spring;

import xp.ass.imitate.config.EnvMeta;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chent3
 * @date 2024/7/24
 */
public class ConfigPropertySourceFactory {

    public static final ConfigPropertySourceFactory INSTANCE = new ConfigPropertySourceFactory();

    private ConfigPropertySourceFactory() {
    }

    List<ConfigPropertySources> configPropertySourcesList = new ArrayList<>();

    public ConfigPropertySources getConfigPropertySource(EnvMeta envMeta, ConfigSource configSource) {

        String configId = String.format("%s_%s_%s", envMeta.getNamespace(), envMeta.getEnv(), envMeta.getAppId());

        ConfigPropertySources configPropertySources = new ConfigPropertySources(configId, configSource);

        configPropertySourcesList.add(configPropertySources);
        return configPropertySources;
    }

    public List<ConfigPropertySources> getConfigPropertySourcesList(){
        return this.configPropertySourcesList;
    }

}
